<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

    <meta charset="UTF-8">
    <title>复制流程</title>

<div class="body-main">
    <form id="flowCopy" action="">
        <input type="hidden" name="flowId" value="${ScFlow.id}"/>
    <table class="add-table form-table">
        <tr>
            <th><span class="required">所属事业部：</span></th>
            <td>
                <input type="text" style="width: 240px" class="input-style"
                       id="selectTreeAddressIdCopy" name="selectTreeAddressIdCopy" autocomplete="off"
                       data-id="" data-orgid="" placeholder="请选择最下级的所属事业部"/>
            </td>
        </tr>
        <tr>
            <th><span class="required">业态：</span></th>
            <td>
                <div id="business_typeCode">
                    <input type="hidden" name="typeCodeId" class="plug-in-msg"/>
                    <input type="hidden" name="typeCodeCopy" id="typeCodeCopy" class="plug-in-code"/>
                    <input type="text" readonly placeholder="请选择业态" class="chose-plugIn layui-input"
                           name="businessTypeName">
                    <div class="bus-picker">
                        <div class="bus-picker-tab">
                            <a href="javascript:void(0);" class="active">请选择业态</a>
                        </div>
                        <div class="bus-picker-content"></div>
                    </div>
                </div>
            </td>
        </tr>
        <tr>
            <th><span class="required">业务办理周期：</span></th>
            <td>
                <label class="input-unit">
                    <input type="text" class="input-style" name="blDate" value="${ScFlow.managementCycle}"
                    />
                    <span class="unit">天</span>
                </label>
            </td>
        </tr>
        <tr>
            <th><span class="required">工作日/自然日：</span></th>
            <td>
                <select class="select-style" name="isnaturalorworkday">
                    <option value="1" <c:if test="${ScFlow.isnaturalorworkday==1}">selected</c:if>>工作日</option>
                    <option value="2" <c:if test="${ScFlow.isnaturalorworkday==2}">selected</c:if>>自然日</option>
                </select>
            </td>
        </tr>
        <tr>
            <th><span>审核级数：</span></th>
            <td>
                <select class="select-style" name="examinGrade">
                    <option value="1" <c:if test="${ScFlow.examineGrade==1}">selected</c:if>>一级</option>
                    <option value="2" <c:if test="${ScFlow.examineGrade==2}">selected</c:if>>二级</option>
                    <option value="3" <c:if test="${ScFlow.examineGrade==3}">selected</c:if>>三级</option>
                    <option value="4" <c:if test="${ScFlow.examineGrade==4}">selected</c:if>>四级</option>
                    <option value="5" <c:if test="${ScFlow.examineGrade==5}">selected</c:if>>五级</option>
                    <option value="6" <c:if test="${ScFlow.examineGrade==6}">selected</c:if>>六级</option>
                    <option value="7" <c:if test="${ScFlow.examineGrade==7}">selected</c:if>>七级</option>
                    <option value="8" <c:if test="${ScFlow.examineGrade==8}">selected</c:if>>八级</option>
                    <option value="9" <c:if test="${ScFlow.examineGrade==9}">selected</c:if>>九级</option>
                    <option value="10" <c:if test="${ScFlow.examineGrade==10}">selected</c:if>>十级</option>
                </select>
            </td>
        </tr>
    </table>
    </form>
</div>
<script type="text/javascript">
    var isSyb = false;
    //属性初始化
    $(function () {
        $('#selectTreeAddressIdCopy').selectTree({
            width:'240px',
            check: false,   //默认为false，单选；设置为 true ，为多选
            search: true,
            parentIsCheck: true,
            url: cmsBaseUrl + "/api/cms/org/v1/find_all_parent_orgs.do?level=ORG_LEVEL_1&isFilterAB=1",//请求路 径
            form: true,
            idName: 'orgId',
            idKey: "id",//指定id
            pIdKey: "pId",//指定pId
            dataFilter: function (treeId, parentNode, responseData) {
                return responseData.data;
            },
            changeFun: function () {
                // 选择的不是事业部
                if (!findOrgInfo($('[name="selectTreeAddressIdCopy"]').attr("data-id"))) {
                    DGG.Warning('请选择层级为事业部的部门！');
                    // $('[name="selectTreeAddressIdCopy"]').attr("data-id","");
                    // $('[name="selectTreeAddressIdCopy"]').val("");
                    isSyb = false;
                } else {
                    isSyb = true;
                }
            }
        });
        //初始化下拉数据
    });
    $(document).ready(function () {
        Plug.plug_ins("post", "${basePath}/zzsc/common/tree_book_list.do?code=BUS_YT_ZZ&&type=2&&level=2", "#business_typeCode", '选择业态', '', true, 'BUS_YT_ZZ', '', '');
    });

    function flowCopy() {
        var addressDeptId = $('[name="selectTreeAddressIdCopy"]').val();
        var busYtCode = $('[name="typeCodeCopy"]').val();
        var blDate = $('[name="blDate"]').val();
        var isnaturalorworkday = $('[name="isnaturalorworkday"]').val();
        var examinGrade = $('[name="examinGrade"]').val();

        var busYtName = $('[name="typeCodeCopy"]').find("option:selected").text();


        if (!isSyb) {
            DGG.Warning('请选择层级为事业部的部门！');
            return;
        }
        if (!busYtCode) {
            DGG.Warning('请选择业态！');
            return;
        }

        //判断业态是否选择到最下级
        /* var n = (busYtCode.split('_')).length - 1;
         if (n != 3) {
             DGG.Layer.message('请选择正确的业态！', {icon: '0'});
             return;
         }*/

        if (!blDate) {
            DGG.Warning('请选择业务办理周期!');
            return;
        }
        if (!isIntGte('[name="blDate"]', false)) return flag = false;
        if (!isInLength('[name="blDate"]', 0, 5)) return flag = false;

        var params = $('#flowCopy').serializeArray();
        DGG.Confire("确定复制流程吗？", '复制流程', function () {
            DGG.loading();
            $.ajax({
                type: 'POST',
                async: true,
                data: params,
                url: sysInfo.basePath + '/zzsc/flownode/copy_flow_save.do',
                dataType: 'JSON',
                success: function (data) {
                    DGG.loading('close');
                    if (data.code == 0) {
                        DGG.Succeed('操作成功！');
                        setTimeout(function () {
                            layer.closeAll();
                        }, 1000);
                        reloadTable1();
                    } else {
                        DGG.Errors(data.msg);
                    }
                },
                error: function () {
                    DGG.Errors('保存失败，请联系管理员！！');
                }
            })
        }, function () {
        })
    }

</script>
